<template>
  <view class="forward">
<!--    <view class="list">-->
      <view class="forward-item" v-for="(item, index) in forward" :key="index" @click="jumpDetails(item.targetId)">
        <view class="forward-img">
          <image :src="item.image"></image>
<!--          {{item.image}}-->
        </view>
        <view class="forward-info">
          <view class="forward-name">{{ item.name }}</view>
          <text class="price-text">¥{{ item.price }}<text class="forward-ageRange">{{ item.ageRange }}</text></text>

          <view class="forward-time">{{ item.shareTime.substr(0, 10) }}</view>
        </view>
      </view>
<!--    </view>-->
  </view>
</template>

<script>
import {getForwardList} from "../../../api/new";
import {
  mapGetters
} from "vuex";
export default {
  computed: mapGetters(['isLogin']),
  name: "index",
  data() {
    return {
      forward:[
        {
          image:'我是图片',
          name:'我是名字',
          ageRange:'适用年龄',
          price:'价格',
          time:'分享的时间'
        },
        {
          image:'我是图片',
          name:'我是名字',
          ageRange:'适用年龄',
          price:'价格',
          time:'分享的时间'
        },
      ],
      propagation:{
        limit:10,
        page:1,
      }
    }
  },
  methods:{
    jumpDetails(id){
      uni.navigateTo({
        url: '/pages/discover/courseDetails/index?id=' + id
      })
    },
    getList(){
      getForwardList(this.propagation).then(res=>{
        if (this.propagation.page === 1) {
          this.forward=res.data.list
        } else {
          this.forward = [...this.forward, ...res.data.list];
        }
        this.propagation.page=res.data.page+1
      })
    },
  },
  onReachBottom(){
    if (this.isLogin) {
      this.getList()
    }
  },
  onShow: function () {
    if (this.isLogin) {
      this.getList()
    }
  },
}
</script>

<style scoped lang="scss">

$colorTit: #231917;
$colorContent: #53433F;

.forward{
  padding: 15px;

  .list{
    background-color: #fff;
    padding: 20rpx;
  }
  .forward-item {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 10px;
    margin-bottom: 15px;
    overflow: hidden;
    padding: 15px;
    .forward-img {
      width: 100px;
      height: 100px;
      margin-right: 15px;
      image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 10px;
      }
    }

    .forward-info {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .forward-name {
        font-size: 16px;
        color: $colorTit;
        margin-bottom: 5px;
      }

      .price-text {
        color: #B33B15;
      }

      .forward-ageRange{
        color: #6B7280;
        margin-left: 20rpx;
      }

      .forward-time{
        color: #a7a7a7;
      }
    }
  }
}
</style>